/***************************************************************************
 *   Copyright (C) 2009 by Bernhard Neuhofer   *
 *   mail@bneu.at   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef CORBAMESSAGEHANDLER_H
#define CORBAMESSAGEHANDLER_H


#include "messageHandler.h"
#include "message.h"
#include "vectorBuffer.h"

#include <map>


/**
* Concrete implementation of a message handler using CORBA (Strategie Pattern)
*/

class CorbaMessageHandler:public MessageHandler
{
	private:
	//The message buffers of the MHs local clients are stored in here
	map<unsigned int ,VectorBuffer*> _clients;


	public:
	
	/**
	 *        @see MessageHandler#sendMessage
	 * @param message 
	 */
	void sendMessage(Message* message);

	/**
	 *        @see MessageHandler#recieve Message
	 * @param message 
	 */
	void receiveMessage(Message* message);

	/**
	 *        @see MessageHandler#addClient
	 * @param id 
	 */
	void addClient(unsigned int id);

	/**
	 *        @see MessageHandler#bufferEmpty
	 * @param id 
	 * @return 
	 */
	bool bufferEmpty(unsigned int id);

	/**
	 *        @see MessageHandler#totalMsgs
	 * @return 
	 */
	unsigned int totalMsgs();

	/**
	 *        @see MessageHandler#readBuffer
	 * @param id 
	 * @return 
	 */
	Message* readBuffer(unsigned int id);

	/**
	 *        @MessageHandler#bufferSize
	 * @param id 
	 * @return 
	 */
	unsigned int bufferSize(unsigned int id);

};


#endif